import axios from 'axios';

import { axiosConfig } from '../env.js';

const apiClient = axios.create({
  ...axiosConfig,
  timeout: 600000, // 设置更长的超时时间以应对批量操作
});

/**
 * Execute custom batch collection
 * POST /api/v1/batch-collection/execute
 */
export const executeBatchCollection = (payload) => {
  return apiClient.post('/v1/batch-collection/execute', payload);
};

/**
 * Execute a preset plan
 * POST /api/v1/batch-collection/execute/plan/{planCode}
 */
export const executePlan = (planCode, payload) => {
  return apiClient.post(`/v1/batch-collection/execute/plan/${encodeURIComponent(planCode)}`, payload);
};

/**
 * Optional: fetch scheduler status (if backend provides)
 * GET /api/v1/batch-collection/scheduler/status
 */
export const getSchedulerStatus = () => {
  return apiClient.get('/v1/batch-collection/scheduler/status');
};

/**
 * Trigger announcement update
 * POST /api/announcement/update/trigger/{mode}
 */
export const triggerAnnouncementUpdate = (mode, payload = {}) => {
  return apiClient.post(`/announcement/update/trigger/${mode}`, payload);
};

/**
 * Trigger holding update
 * POST /api/holding/update/trigger/{mode}
 */
export const triggerHoldingUpdate = (mode, payload = {}) => {
  return apiClient.post(`/holding/update/trigger/${mode}`, payload);
};


